﻿using System.Linq;
using System.Security.Cryptography;
using System.Text;

namespace Common.Extensions
{
    public static class StringExtensions
    {
        public static string CreateHash(this string value)
        {
            byte[] bytes = Encoding.Unicode.GetBytes(value);
            MD5CryptoServiceProvider csp = new MD5CryptoServiceProvider();
            byte[] byteHash = csp.ComputeHash(bytes);
            //формируем одну цельную строку из массива  
            return byteHash.Aggregate(string.Empty, (current, b) => current + string.Format("{0:x2}", b));
        }
    }
}